// PersistRegBase.h: interface for the PersistRegBase class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_PERSISTREGBASE_H__A5C1048F_B938_4E5C_8BDD_E2C598C01F83__INCLUDED_)
#define AFX_PERSISTREGBASE_H__A5C1048F_B938_4E5C_8BDD_E2C598C01F83__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "UeObjectID.h"
#include "newRegister.h"

class Persistable;
namespace PDMS
{
	namespace PDMSDBIF
	{
		class DatabaseBase;
		class PersisterIF;
		typedef SingletonRegObject< const RuntimeClass_*, PersisterIF > PersistRegSurperClass;
		typedef PersistRegSurperClass::Register_ PersistenceManagerIF;

		class PersisterIF : public PersistRegSurperClass
		{
			DECLARE_DYNAMIC_EX( PersisterIF );
		public:
			PersisterIF() {
			m_pDB = NULL;
			}
			virtual ~PersisterIF(){
			}

			virtual UESoft::ErrorStatus Retrieve( Persistable*& pObj ) = 0;
			virtual UESoft::ErrorStatus Create( Persistable* pObj ) = 0;
			virtual UESoft::ErrorStatus Update( Persistable* pObj ) = 0;
			virtual UESoft::ErrorStatus Delete( Persistable* pObj ) = 0;
			
		public:
			void SetDatabase( DatabaseBase* pDB ) {
				m_pDB = pDB;
			}
			
			DatabaseBase* GetDatabase() const {
				return m_pDB;
			}
			
		private:
			DatabaseBase* m_pDB;
		};


		class PersistRegBase : public PersisterIF										 
		{
			DECLARE_DYNAMIC_EX( PersistRegBase );
			DECLARE_REGISTER( VersionOne );
		public:
			PersistRegBase();
			virtual ~PersistRegBase();
			virtual UESoft::ErrorStatus Delete( Persistable* pObj )
			{
				return UESoft::eOk;
			}
			
		protected:
			UESoft::ErrorStatus CreatePaternity( Persistable* pObj );
			UESoft::ErrorStatus ReadPaternity( Persistable* pObj );
		};
	}
}

#endif // !defined(AFX_PERSISTREGBASE_H__A5C1048F_B938_4E5C_8BDD_E2C598C01F83__INCLUDED_)
